package com.ldc.security.utils;

import com.ldc.common.constants.ConstantsParams;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @auther liudc
 * @since 2022/11/14
 */
public class SecurityHttpUtils {
    /**
     * 获取token
     *
     * @param request 请求体
     * @return token
     */
    public static String getToken(HttpServletRequest request) {
        String token = request.getHeader(ConstantsParams.TOKEN);
        if (StringUtils.isEmpty(token)) {
            return request.getParameter(ConstantsParams.TOKEN);
        }
        return token;
    }
}
